<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of FluxService
 *
 * @author ingeni
 */
class FluxServiceSupp {
    //put your code here
    public function display(ContextExecution $p_contexte){
        $userid = $p_contexte->getUser()->userId;
        $fluxid = $p_contexte->m_dataRequest->getData('fluxId');
        if($fluxid==null){
//            $numeroPage=$p_contexte->m_dataRequest->getData('numeroPage');
//            $listFlux = new ListObject();
//            $listFlux->name='ListeFlux';
//            $listFlux->request('Flux', "userId='$userid'", $numeroPage);
//            $p_contexte->addDataBlockRow($listFlux);
        } else {
//            $flux = new Flux();
//            $flux->fluxId=$fluxid;
//            $flux->userId=$userid;
//            $flux->load();
//            $p_contexte->addDataBlockRow($flux);
//            
//            $listeCompte = new ListObject();
//            $listeCompte->name='ListeComptes';
//            $listeCompte->request('Comptes', "userId=$userid");
//            $p_contexte->addDataBlockRow($listeCompte);
        }
    }
    
    public function update(ContextExecution $p_contexte){
        $userid = $p_contexte->getUser()->userId;
        $fluxid = $p_contexte->m_dataRequest->getData('fluxId');
        $flux = new Flux();
        $flux->fluxId=$fluxid;
        $flux->userId=$userid;
        $flux->load();
        $flux->fieldObject($p_contexte->m_dataRequest);
        Logger::getInstance()->addLogMessage("flux:".$flux->flux);
        $flux->save();
    }
    
    public function create(ContextExecution $p_contexte){
        $userid = $p_contexte->getUser()->userId;
        $flux = new Flux();
        $flux->userId=$userid;
        $flux->fieldObject($p_contexte->m_dataRequest);
        $flux->save();
    }
    
    
}

?>